<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<link rel="stylesheet" href="#(CONTEXT_PATH)/static/lib/layui/css/layui.css">
		<script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
		<script src="#(CONTEXT_PATH)/static/lib/layui/layui.js" charset="utf-8"></script> 
		<style type="text/css">
    		tr{height: 30px;}
    	</style>
    
	</head>
	<body>
		<br>
		<form id="editForm" class="layui-form" action="" onsubmit="submitForm()" style="width:90%">
		<input type="hidden" id="id" name="id" value="#(sale_order.id??)"  />
		<table style="margin: 20px;height: 30px;width:80%;">
			<tr>
				<td>订单编号</td>
				<td>#(sale_order.no??)</td>
			</tr>
			<tr>
				<td>客户</td>
				<td>#(sale_order.partner.company_name??)</td>
			</tr>
			
			<tr>
				<td>总金额</td>
				<td>#(sale_order.money??)</td>
			</tr>
			
		</table>
		
		<div class="layui-tab">
		  <ul class="layui-tab-title">
		    <li class="layui-this">商品明细</li>
		  </ul>
		  <div class="layui-tab-content">
		    <div class="layui-tab-item layui-show">
		    	<table  class="layui-table">
		    		<thead>
					    <tr>
					      <th>图片</th>
					      <th>名称</th>
					      <th>数量</th>
					      <th>单价</th>
					      <th>小计</th>
					    </tr> 
					  </thead>
					  <tbody>
					  	#for(l : sale_order.lines)
					    <tr>
					      <td>
							<img src="#(CONTEXT_PATH??)/upload/temp/#(l.goods.img??)" />
							</td>
					      <td>#(l.goods.name??)</td>
					      <td>#(l.goods_count??)</td>
					      <td>#(l.goods_price??)</td>
					      <td>#(l.money??)</td>
					    </tr>
					    #end
					   </tbody>
		    	</table>
		    </div>
		  </div>
		</div>
  		</form>
  		
	</body>
	<script>
		var layer;
		var element;

		$(function(){
			layui.use(['form','element'],
			    function() {
		        layer = layui.layer;
		        element = layui.element;
		     });
		});
		
		function refresh(){
			console.log("aaa " + parent.currentTab);
			var obj = getCurrentTab();
			var src = obj.attr("src");
			alert(src);
		}
		
		function getCurrentTab(){
			var obj = parent.$("iframe[class='x-iframe']:eq("+parent.currentTab+")");
			return obj[0];
		}
		
		function check(){
			var formData = {
				id:$("#id").val(),
				state:$("#state").val()
			}
            $.post('#(CONTEXT_PATH)/sale_order/check',formData,function(data) {
				//alert('完成');
				var obj = getCurrentTab();
				console.log(obj);
				obj.contentWindow.query();
				obj.contentWindow.closeWin();
           });
		}
		
		function confirmTuihuo(){
			var formData = {
				id:$("#id").val(),
				state:'checked'
			}
            $.post('#(CONTEXT_PATH)/sale_order/confirmTuihuo',formData,function(data) {
				//alert('完成');
				var obj = getCurrentTab();
				console.log(obj);
				obj.contentWindow.query();
				obj.contentWindow.closeWin();
           });
		}
		
		function confirmPeikuan(){
			var formData = {
				id:$("#id").val(),
				state:'fail'
			}
            $.post('#(CONTEXT_PATH)/sale_order/confirmPeikuan',formData,function(data) {
				//alert('完成');
				var obj = getCurrentTab();
				console.log(obj);
				obj.contentWindow.query();
				obj.contentWindow.closeWin();
           });
		}

		function sendGoods(){
			var formData = {
				id:$("#id").val(),
				chuhuo:$("#chuhuo").val()
			}
            $.post('#(CONTEXT_PATH)/sale_order/chuhuo',formData,function(data) {
				//alert('完成');
				var obj = getCurrentTab();
				console.log(obj);
				obj.contentWindow.query();
				obj.contentWindow.closeWin();
           });
		}
		
		function submitForm(){
			submitData();
		}
		
	</script>
</html>
